import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {LoginComponent} from './components/login/login/login.component';
import {LoginAutherGuard} from './login-auther/login-auther.guard';
import {ContainerComponent} from './components/container/container.component';
import {RegisterComponent} from './components/login/register/register.component';
import {NewsHomeComponent} from './components/news/news-home/news-home.component';
import {NewsContentComponent} from './components/news/news-content/news-content.component';
import {ManagementHomeComponent} from "./components/management/management-home/management-home.component";
import {AdviceHomeComponent} from './components/advice/advice-home/advice-home.component';
import {PolicyHomeComponent} from './components/policy/policy-home/policy-home.component';
import {CasesHomeComponent} from './components/case/cases-home/cases-home.component';
import {CapitalHomeComponent} from './components/capital/capital-home/capital-home.component';
import {AffairsHomeComponent} from './components/affairs/affairs-home/affairs-home.component';
import {DownloadHomeComponent} from './components/download/download-home/download-home.component';
import {DirectoriesHomeComponent} from './components/directories/directories-home/directories-home.component';
import {ComplaintHomeComponent} from './components/complaint/complaint-home/complaint-home.component';
import {QuestionHomeComponent} from './components/question/question-home/question-home.component';
import {LogHomeComponent} from './components/log/log-home/log-home.component';

const routes: Routes = [
  {
    path: '',
    /*用户保护是否有权限访问子路路由模块*/
    canActivate: [LoginAutherGuard],
    children: [
      {
        path: '',
        component: ContainerComponent,
        children: [
          /*展示路由界面*/
          {path: '', redirectTo: 'newsHome', pathMatch: 'full'},
          {path: 'newsHome', component: NewsHomeComponent},
          {path: 'manageAgency', component: ManagementHomeComponent},
          {path: 'advice', component: AdviceHomeComponent},
          {path: 'policy', component: PolicyHomeComponent},
          {path: 'cases', component: CasesHomeComponent},
          {path: 'capital', component: CapitalHomeComponent},
          {path: 'affairs', component: AffairsHomeComponent},
          {path: 'download', component: DownloadHomeComponent},
          {path: 'directories', component: DirectoriesHomeComponent},
          {path: 'complaint', component: ComplaintHomeComponent},
          {path: 'question', component: QuestionHomeComponent},
          {path: 'log', component: LogHomeComponent}
        ]
      },
    ]
  },
  {path: 'login', component: LoginComponent},
  {path: 'register', component: RegisterComponent},
  {path: '**', component: RegisterComponent}
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  exports: [
    RouterModule
  ]
})
export class AppRoutingModule {
}
